package com.xyoto.takeawayBusiness.controller;

import com.xyoto.takeawayBusiness.dto.WxLoginDTO;
import com.xyoto.takeawayBusiness.service.WechatAuthService;
import com.xyoto.takeawayBusiness.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author Administrator
 */
@Api(tags = "微信授权模块")
@RestController
@RequestMapping("/wechat")
public class AuthController {

    @Autowired
    private WechatAuthService wechatAuthService;

    @ApiOperation("开发者授权登录")
    @PostMapping("/devAuthLogin")
    public Result devAuthLogin() {
        return wechatAuthService.devAuthLogin();
    }

    @ApiOperation("微信授权登录")
    @PostMapping("/login")
    public Result login(@Valid @RequestBody WxLoginDTO wxLoginDTO) {
        return wechatAuthService.login(wxLoginDTO);
    }

    @ApiOperation("校验Token")
    @PostMapping("/checkToken")
    public Result checkToken() {
        return wechatAuthService.checkToken();
    }

    @ApiOperation("退出登录")
    @PostMapping("/logout")
    public Result logout(){
        return wechatAuthService.logout();
    }

}
